import java.util.Arrays;

/**
 * @program: java_oj
 * @author: JCM
 * @create: 2023-08-31 15:51
 * @description:
 **/
public class Solution {
    public int[] twoSum(int[] nums, int target) {
        int[] a = {0,1};
        return a;
    }
    public int fib(int n) {
        return n;
    }

    public void reverseString(char[] s) {

    }

    public int uniquePaths(int m, int n) {
        return 3;
    }
    public static void main1(String[] args) {
        Solution solution = new Solution();
        int[] nums = {2,7,11,15};
        int target = 9;
        int[] result = solution.twoSum(nums,target);
        if (result.length == 2 && (nums[result[0]] + nums[result[1]]) == target) {
            System.out.println("testcase1 OK");
        }else {
            System.out.println("testcase1 failed");
        }
        // test2
        int[] nums2 = {1,2,3,4,0};
        int target2 = 7;
        int[] result2 = solution.twoSum(nums2,target2);
        if (result2.length == 2 && (nums2[result2[0]] + nums2[result2[1]]) == target2) {
            System.out.println("testcase2 OK");
        }else {
            System.out.println("testcase2 failed");
        }
    }

    public static void main2(String[] args) {
        Solution solution = new Solution();
        int n1 = 1;
        int res1 = solution.fib(n1);
        if(res1 == 1) {
            System.out.println("testcase1 OK");
        }else {
            System.out.println("testcase1 failed");
        }
        int n2 = 2;
        int res2 = solution.fib(n2);
        if(res2 == 1) {
            System.out.println("testcase2 OK");
        }else {
            System.out.println("testcase2 failed");
        }
        int n3 = 10;
        int res3 = solution.fib(n3);
        if(res3 == 55) {
            System.out.println("testcase3 OK");
        }else {
            System.out.println("testcase3 failed");
        }
        int n4 = 21;
        int res4 = solution.fib(n4);
        if(res4 == 10946) {
            System.out.println("testcase4 OK");
        }else {
            System.out.println("testcase4 failed");
        }

    }

    public static void main3(String[] args) {
        Solution solution = new Solution();
        char[] chs1 = {'h','e','l','l','o'};
        char[] chs1_copy = chs1.clone();
        solution.reverseString(chs1);
        boolean f1 = true;
        for(int i = 0,j = chs1_copy.length-1;i <= j; i++,j--) {
            if(chs1[j] != chs1_copy[i]) {
                f1 = false;
                System.out.println("testcase1 failed");
                break;
            }
        }
        if(f1) System.out.println("testcase1 OK");
        char[] chs2 = {'H','a','n','n','a','h'};
        char[] chs2_copy = chs2.clone();
        solution.reverseString(chs2);
        boolean f2 = true;
        for(int i = 0,j = chs2_copy.length-1;i <= j; i++,j--) {
            if(chs2[j] != chs2_copy[i]) {
                f2 = false;
                System.out.println("testcase2 failed");
                break;
            }
        }
        if(f2) System.out.println("testcase2 OK");

    }

    public int uniquePathsAns(int m, int n) {
        int[][] dp = new int[m][n];
        // 初始化 dp
        for(int i = 0; i < m; i++)
            dp[i][0] = 1;
        for(int j = 0; j < n; j++)
            dp[0][j] = 1;
        // 递归公式
        // dp[m-1][n-1] = dp[m-2][n-1] + dp[m-1][n-2];
        for(int i = 1; i < m; i++) {
            for(int j = 1; j < n; j++) {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
        }
        return dp[m-1][n-1];
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        boolean f = true;
        int m1 = 3, n1 = 7;
        if(solution.uniquePaths(m1,n1) != solution.uniquePathsAns(m1,n1)) {
            f = false;
            System.out.println("testcase1 failed");
        }
        int m2 = 3, n2 = 2;
        if(solution.uniquePaths(m2,n2) != solution.uniquePathsAns(m2,n2)) {
            f = false;
            System.out.println("testcase2 failed");
        }
        int m3 = 7, n3 = 3;
        if(solution.uniquePaths(m3,n3) != solution.uniquePathsAns(m3,n3)) {
            f = false;
            System.out.println("testcase3 failed");
        }
        int m4 = 3, n4 = 4;
        if(solution.uniquePaths(m4,n4) != solution.uniquePathsAns(m4,n4)) {
            f = false;
            System.out.println("testcase4 failed");
        }
        if (f) {
            System.out.println("all testcase OK");
        }
    }
}
